package com.njchy.statistics.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Min;
import java.util.concurrent.RejectedExecutionHandler;

/**
 * 线程池配置实体类：绑定 thread-pool.point-match 前缀的参数
 */
@Data 
@Validated  // 可选：开启参数校验，防止非法配置（如核心线程数为0）
@ConfigurationProperties(prefix = "thread-pool.point-match") // 前缀必须与配置文件一致
public class PointMatchThreadPoolProperties {

    @Min(value = 1, message = "核心线程数不能小于1")
    private Integer corePoolSize;

    @Min(value = 1, message = "最大线程数不能小于1")
    private Integer maxPoolSize;

    @Min(value = 1, message = "队列容量不能小于1")
    private Integer queueCapacity;

    @Min(value = 1, message = "空闲线程存活时间不能小于1秒")
    private Integer keepAliveSeconds;

    private String threadNamePrefix;

    // 与配置文件的 rejected-execution-handler 对应，Spring会用转换器转为实例
    private RejectedExecutionHandler rejectedExecutionHandler;
}